# encoding='utf-8'
import requests

ipaddress = "http://172.16.0.254:8080"


class LoginApi():

    def login(self):
        uri = f'{ipaddress}/login'
        mydata = {"username": "17513230012", "password": "123456"}
        r = requests.post(uri, data=mydata)
        print(r)
        print(r.text)
        print(r.json())
        return r

    def getToken(self):
        r = self.login()
        self.token = r.json()['Admin-Token']
        return self.token

    def login_error_1(self):
        return self.getToken(self.msg_not)

    def login_error_2(self):
        return self.getToken(self.msg_null)


if __name__ == "__main__":
    LoginApi().getToken()
